package com.jyxd.web.log;

import javax.servlet.http.HttpSession;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.Date;

public class ClassTypeJudge {
    /**
     * 判断一个类是否为基本数据类型。
     *
     * @param clazz 要判断的类。
     * @return true 表示为基本数据类型。
     */
    public static boolean isBaseDataType(Class clazz) {
        boolean result = true;
        try {
            result = (clazz.equals(String.class) ||
                    clazz.equals(Byte.class) ||
                    clazz.equals(Long.class) ||
                    clazz.equals(Double.class) ||
                    clazz.equals(Float.class) ||
                    clazz.equals(Character.class) ||
                    clazz.equals(Short.class) ||
                    clazz.equals(BigDecimal.class) ||
                    clazz.equals(BigInteger.class) ||
                    clazz.equals(Boolean.class) ||
                    clazz.equals(Date.class) ||
                    clazz.equals(java.sql.Date.class) ||
                    clazz.equals(HttpSession.class) ||
                    clazz.equals(org.apache.catalina.session.StandardSessionFacade.class) ||
                    clazz.equals(org.springframework.session.web.http.SessionRepositoryFilter.class) ||
                    clazz.isPrimitive());
        } catch (Exception ex) {
            System.out.println("不做处理");
        }
        return result;
    }

}
